﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management.Automation;
using System.Net;
using System.Xml;
using System.IO;
using GoGrid;

namespace Readify.Management.Automation.GoGrid
{
    [Cmdlet("Get", "GoGridIPAddress")]
    public class GetGoGridIPAddressCmdlet : GoGridCmdletBase
    {
        [Parameter()]
        public SwitchParameter Public { get; set; }

        [Parameter()]
        public SwitchParameter Unassigned { get; set; }

        protected override void ProcessRecord()
        {
            Connection connection = this.GetConnection();

            List<global::GoGrid.IPAddress> addresses = connection.ListIPAddresses(
                this.Unassigned ? IPAddressState.Unassigned : IPAddressState.Any,
                this.Public ? IPAddressType.Public : IPAddressType.Any,
                Paging.None
                );

            foreach (global::GoGrid.IPAddress address in addresses)
            {
                this.WriteObject(address);
            }
        }
    }
}
